﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace coffeeShops
{
    class GridNode
    {
        public int x = 0;
        public int y = 0;
        public int radius = 0;
        public int bitrate = 0;
        public GridNode(int x, int y, int radius, int bitrate)
        {
            this.x = x;
            this.y = y;
            this.radius = radius;
            this.bitrate = bitrate;
        }
    }    
    class Program
    {
        static void Main(string[] args)
        {

            StreamReader reader = File.OpenText("s5.in");
            int EastWest = int.Parse(reader.ReadLine());
            int NorthSouth = int.Parse(reader.ReadLine());
            int lines = int.Parse(reader.ReadLine());
            GridNode[] coffeeShopsWithWireless = new GridNode[lines];
            int maxBitRate = 0;
            int numberOfCoffeeShopsWithMaxBitRate = 0;
            for (int i = 0; i < lines; i++)
            {
                string line = reader.ReadLine();
                string[] lineNumbers = line.Split(' ');
                coffeeShopsWithWireless[i] = new GridNode(int.Parse(lineNumbers[0]) - 1, int.Parse(lineNumbers[1]) - 1, int.Parse(lineNumbers[2]), int.Parse(lineNumbers[3]) );
                Console.WriteLine("Grid Node at " + coffeeShopsWithWireless[i].x.ToString() + "," + coffeeShopsWithWireless[i].y.ToString() + " Radius: " + coffeeShopsWithWireless[i].radius + " Bitrate: " + coffeeShopsWithWireless[i].bitrate);
            }
            for (int y = 0; y < EastWest; y++)
            {
                for (int x = 0; x < NorthSouth; x++)
                {
                    int localBitRate = 0;
                    for (int i = 0; i < coffeeShopsWithWireless.Length; i++)
                    {
                        double distance = Math.Sqrt((double)(
                            Math.Pow((coffeeShopsWithWireless[i].x - x), 2) +
                            Math.Pow((coffeeShopsWithWireless[i].y - y), 2)));
                        //Console.WriteLine(distance.ToString());
                        if (distance <= coffeeShopsWithWireless[i].radius)
                            localBitRate += coffeeShopsWithWireless[i].bitrate;
                    }
                    Console.WriteLine("(" + x.ToString() + "," + y.ToString() + ") has a bitrate of " + localBitRate.ToString());
                    if (localBitRate == maxBitRate)
                    {
                        numberOfCoffeeShopsWithMaxBitRate += 1;
                    }
                    else if (localBitRate > maxBitRate)
                    {
                        maxBitRate = localBitRate;
                        numberOfCoffeeShopsWithMaxBitRate = 1;
                    }
                }
            }
            Console.WriteLine(/*"MaxBitRate = " + */maxBitRate.ToString());
            Console.WriteLine(/*"# of coffee shops with max BitRate: " + */numberOfCoffeeShopsWithMaxBitRate.ToString());
            Console.ReadLine();
        }
    }
}
